/**
 * Created by castle on 2015/06/02.
 */
var AddStudent = function(){
    var SUIDs = [];
    return {
        init:function(){
            $("#btn-SUID").click(function(){
                var SUID = $('#SUID').val();
                if(SUID>20000000){
                    $.ajax({
                        url:'http://api.tansuyun.cn?i=9GetStudent&tsy='+getCookie('tsy'),
                        data:{SUID:SUID},
                        method:'post',
                        type:'json',
                        success: function (d) {
                            if(d.c==200){
                                var html = '<tr class="gradeX odd">'+'<td class="  sorting_1" >'+'<input type="checkbox" name="checkbox" value=""></td>'+'<td class="">'+ d.d[0].SUID+'</td>'+'<td class="hidden-480 ">'+d.d[0].StudentName+'</td><td class="hidden-480 ">'+d.d[0].ClassNumber+'</td>'+'</tr>';
                                $('#StudentInfo').append(html);
                                SUIDs.push(SUID);
                            }
                        }
                    });
                }else{
                    alert('学号不规范');
                }
            });
            $("#AddStudentToActivity").click(function(){
                $.ajax({
                    url:'http://api.tansuyun.cn?i=9JoinActivity&tsy='+getCookie('tsy'),
                    data:{SUIDS:SUIDs,ActID: getCookie('ActID'),'Evaluation':1},
                    method:'post',
                    type:'json',
                    success: function (d) {
                        if(d.c==200){
                            alert('添加成功');
//                            window.history.back();
                        }else{
                            alert('添加失败');
                        }
                    }

                });
            });
        }
    };
}();